package com.project.mvprxsample.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 存放各种系统参数
 */
public class SysConfig {
    private final static String SYS_PARMS = "sys_parms";
    private SharedPreferences config;

    private static SysConfig sysConfig;

    public SysConfig(Context context) {
        config = context.getSharedPreferences(SYS_PARMS, 0);
    }

    //单例模式
    public static SysConfig getConfig(Context context) {
        if (sysConfig == null) {
            sysConfig = new SysConfig(context);
        }
        return sysConfig;
    }

    //获取原先配置中的版本号
    public int getAppVesion() {
        return config.getInt("version", 0);
    }

    //写入最新的版本号-
    public void setAppVesion(int version) {
        config.edit().putInt("version", version).commit();
    }


}
